#include <iostream>
using namespace std;
#include <string>
#include <map>
int main(int argc, char**argv)
{
	string s;
	cout << "input string: ";
	getline(cin, s);

	map<char, int> myMap;
#if 0
	for(string::iterator it = s.begin(); it != s.end(); it++){
		pair<map<char, int>::iterator, bool> ret = myMap.insert(pair<char, int>(*it, 1));
		if(!ret.second){
			//失败
			//将已经存在的键值对的值加1
			map<char, int>::iterator mit = ret.first;
			mit->second++;
		}
	}
#endif
#if 0
	for(string::iterator it = s.begin(); it != s.end(); it++){
		map<char,int>::iterator ret = myMap.find(*it);
		if(ret != myMap.end()){
			ret->second++;
		}else{
			myMap.insert(pair<char, int>(*it, 1));
		}
	}
#endif

	//aabbcc  a - 2   b - 2 c - 2
	for(string::iterator it = s.begin(); it != s.end(); it++){
		myMap[*it]++;	
	}

	/*
		for(auto i : s){
			myMap[i]++;
		}
	*/

	for(map<char, int>::iterator it = myMap.begin(); it != myMap.end(); it++){
		cout << it->first << "------------>" << it->second << endl;
	}

	return 0;
}
